package cn.com.mdx.sort.practice.nutsbolts;

/**
 * <p> 螺丝
 *
 * @author ：huangy
 * @date ：Created in 2020/9/25 3:52 下午
 */
public class Screw {
    /**
     * 螺母
     */
    private Nut nut;
    /**
     * 螺帽
     */
    private Bolt bolt;

    public Screw(Nut nut, Bolt bolt) {
        this.nut = nut;
        this.bolt = bolt;
    }

    public String toString() {
        String matchSrc = "未匹配";
        if (isMatchFlag()) matchSrc = "已匹配";
        return "螺母尺寸：" + nut.getSize() + "，螺帽尺寸：" +
                bolt.getSize() + "螺母和螺帽，" + matchSrc;
    }

    public Nut getNut() {
        return nut;
    }

    public void setNut(Nut nut) {
        this.nut = nut;
    }

    public Bolt getBolt() {
        return bolt;
    }

    public void setBolt(Bolt bolt) {
        this.bolt = bolt;
    }

    public boolean isMatchFlag() {
        return nut != null && bolt != null && nut.getSize() == bolt.getSize();
    }
}
